﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.eforcegloabal.crux.web.wrokflows;
using com.eforceglobal.crux.web.wrokflows.DTOs;

namespace com.eforceglobal.crux.BusinessFacades
{
    public class EmailNotificationFacade
    {
        public List<NotificationModeInfo> GetNotificationModes()
        {
            return new WorkflowEmailNotifications().GetNotificationModes().ToList();
        }
        public List<NotificationStateInfo> GetEftNotificationStates()
        {
            return new WorkflowEmailNotifications().GetNotificationStates().ToList();
        }
        public List<NotificationStateModesInfo> GetNotificationStateModeSetByUserId(string userName)
        {
            return new WorkflowEmailNotifications().GetNotificationStateModeSetByUserId(userName).ToList();
        }

        public void SaveModeState(List<NotificationStateModesInfo> stateModeSetInfoList)
        {
            WorkflowEmailNotifications emailNotification = new WorkflowEmailNotifications();
            var userName = stateModeSetInfoList.First().UserName;

            var lstStateModeSetInfo = emailNotification.GetNotificationStateModeSetByUserId(userName).ToList();
            emailNotification.DeleteNotificationStateModeSet(lstStateModeSetInfo);
            if (stateModeSetInfoList.Count == 1)
            {
                if (stateModeSetInfoList[0].NotificationModeId == 0 || stateModeSetInfoList[0].NotificationStateId == 0)
                {
                    return;
                }
            }
            emailNotification.SaveNotificationStateModes(stateModeSetInfoList);
        }
    }
}
